﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Create a new saved search for the authenticated user.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.SavedSearchToolbox.bmp")]
    [Designer(typeof(AddSavedSearchDesigner))]
    [Description("Create a new saved search for the authenticated user.")]
    public class AddSavedSearch : TwitterOperationInvoker<SavedSearch>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AddSavedSearch"/> class.
        /// </summary>
        public AddSavedSearch()
            : base("AddSavedSearch")
        { }

        /// <summary>
        /// The query of the search the user would like to save.
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// The query to save
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [RequiredArgument]
        [Description("The query of the search the user would like to save.")]
        public InArgument<string> Query { get; set; }

        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument queryArgument = new RuntimeArgument("Query", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Query, queryArgument);
            metadata.AddArgument(queryArgument);

            base.CacheMetadata(metadata);
        }

        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("query", Query);

            base.Execute(context);
        }
    }
}
